package net.xdclass.demo.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import net.xdclass.demo.domain.User;

import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;

@RestController
public class SampleController {

    @RequestMapping("/")
    String home(@RequestBody User user, @RequestParam String lang) {
        System.out.println(user.getAge());
        System.out.println(lang);
        return "Hello World!";
    }

    @PostMapping("/test2/{lang}/usr")
    public Map<String,String> testMap(@PathVariable(value = "lang") String lang,@RequestBody User user){
        System.out.println(lang);
    	Map<String,String> map = new HashMap<>();
    	map.put("age", String.valueOf(user.getAge()));
    	map.put("pwd", user.getPwd());
    	return map;
    }
    
    
    @GetMapping("/testjson")
    public Object testjson(){
    	
    	return new User(111, "abc123", "10001000", new Date());
    }
    
    
    
    
}